﻿using System;
using System.Net.NetworkInformation;

namespace FlyingEye.Application.Utils
{
    public class PingException : InvalidOperationException
    {
        public IPStatus IPStatus { get; private set; }

        public PingException(IPStatus status)
        {
            IPStatus = status;
        }
    }

    internal class NetToolkit
    {
        public static void PingAddress(string ip)
        {
            using var ping = new Ping();
            var reply = ping.Send(ip);

            if (reply.Status != IPStatus.Success)
            {
                throw new PingException(reply.Status);
            }
        }
    }
}
